package com.fqgj.xjd.user.service;

import com.fqgj.xjd.user.client.enums.AppCodeEnum;
import com.fqgj.xjd.user.client.request.Mobile;
import com.fqgj.xjd.user.dao.UserAccessDao;
import com.fqgj.xjd.user.dao.UserDao;
import com.fqgj.xjd.user.entity.UserAccessEntity;
import com.qianli.common.enums.AppEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2017/2/26
 * Time: 下午4:03
 */
@Service
public class CheckUserService {

    @Autowired
    private UserAccessDao userAccessDao;

    public Boolean isMobileExist(Mobile mobile) {
        UserAccessEntity entity = userAccessDao.selectUserByMobile(mobile.getMobile());
        return entity != null;
    }
    public Boolean isMobileExist(Mobile mobile, AppCodeEnum  appCodeEnum) {
        UserAccessEntity entity = userAccessDao.selectUserByMobileAndAppCode(mobile.getMobile(), "" + appCodeEnum.getCode());
        return entity != null;
    }
    public UserAccessEntity getUserByMobile(String mobile, String appId) {
        return userAccessDao.selectUserByMobileAndAppCode(mobile, appId);
    }

}
